protocol buffer
Protocol buffers are Google's language-neutral, platform-neutral, extensible mechanism for serializing structured data – think XML, but smaller, faster, and simpler. You define how you want your data to be structured once, then you can use special generated source code to easily write and read your structured data to and from a variety of data streams and using a variety of languages.
Googleが作った、言語・プラットフォームに依存しない、構造化データをシリアライズするための仕組み
protocol bufferから各言語で使用するgRPCのコードを生成する
.protoファイルにスキーマを記述する
書き方あれこれ
repeated
フィールドを配列として扱う時に使う
HogeRequestはusersという、Userの配列を保持する
code:.proto
message HogeRequest {
repeated User users = 1;
}
message User {
string name = 1;
}
repeatedなfieldを持つmessageをrepeatedで持つと、多次元配列が作れる
oneof